<template>
	<view>
		<view class="feedback-content">
			<textarea v-model="content" class="feedback-textarea" placeholder-style="color:#B2B2B2" placeholder="感谢您留下宝贵意见及建议（10-200字）" />
			</view>
		<view>
			<button class="submit-feedback" @click="submitFeedback()">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: ""
			}
		},
		methods: {
			submitFeedback(){
				if(this.content.length >= 10 && this.content.length <= 200){
					if(this.allMath(this.content)){
						uni.showToast({
							icon: "none",
							title: "意见内容不能为纯字母、数字或者符号",
							duration: 2000
						});
						return false
					}
					const path = {
					    app:"wx",
					    api:"api_wx_user_feedback",
					    version:"1.0",
					    type:"2",
					    data:{
					        content: this.content
					    }
					}
					const _this = this;
					console.log('res.data', path)
					_this.sendSock(path, function(res) {
						_this.getSock(res.data)
					})
				}else{
					uni.showToast({
						icon: "none",
						title: "意见内容字符数不得大于200且不得小于10",
						duration: 2000
					});
				}
			},
			getSock(res) {
				if (res !== '{"type":"ping"}') {
					const resj = JSON.parse(res);
					if (resj.code === -1) {
						uni.showToast({
							icon: "none",
							title: resj.message,
							duration: 2000
						});
					} else {
						if (resj.api === "api_wx_user_login") {
							this.$store.commit('login', resj.data);
							this.temporary()
						} else if (resj.api === "api_wx_user_keepLogin") {
							this.temporary()
						}else if(resj.api === "api_wx_user_feedback"){
							uni.showToast({
								icon: "none",
								title: '提交成功',
								duration: 2000
							});
							const _this = this;
							setTimeout(function() {
								const _this = this;
							    uni.navigateTo({
							    	url: '/pages/personal/index' + '?' + _this.version
							    })
							}, 1000);
						}
					}
				}
			}
		}
	}
</script>

<style>
	page{
		background-color: #F6F5F8;
	}
	.feedback-content{
		background-color: #ffffff;
		width: 100%;
		height: 360rpx;
		padding: 30rpx;
	}
	.feedback-textarea{
		width: 100%;
		height: 100%;
	}
	.submit-feedback{
		width:690rpx;
		height:98rpx;
		background:linear-gradient(0deg,rgba(255,195,36,1),rgba(255,211,94,1));
		box-shadow:0rpx 5rpx 5rpx 0rpx rgba(255,195,36,0.2);
		border-radius:49rpx;
		font-size:32rpx;
		font-family:PingFang SC;
		font-weight:bold;
		color:rgba(51,51,51,1);
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top:90rpx;
	}
	.submit-feedback:after{
		content: none;
	}
</style>
